<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 一、promise的实例方法
        // 1.catch: 捕捉promise链上的错误
        // let p = new Promise((resolve, reject) => {
        //     // resolve(111)
        //     reject('错误')
        // })
        // p.then(res=>{
        //     // console.log(res)
        // }).catch(err => {
        //     console.log(err)
        // })

        function fn1() {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve('111')
                }, 1000)
            }) 
        }
        function fn2() {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve('222')
                }, 1000)
            }) 
        }
        function fn3() {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve('333')
                }, 1000)
            }) 
        }

        fn1().then(res => {
            console.log('执行成功', res)
            return fn2()
        }).then(res => {
            console.log('执行成功', res)
            return fn3()
        }).then(res => {
            console.log('执行完成',res)
        })






    </script>
</body>
</html>